<?php
/***************************************************************
*  Copyright notice
*  (c) 2009, jianyuzhu@gmail.com
*  All rights reserved
*  This script is part of the PPEMI project.
***************************************************************/

//
function func_group_output_categories($categories, $categories_id, $level, $name_used = false) {
	$output_str = ''; 
	
	if( sizeof($categories) > 0 ) {
		$name = 'group_category' . $level;
		$id = 'group_category' . $level;
		$action = 'group.selectcategory(this.value, ' . $level . ');return false;';
		$cid = 0 - $categories_id;
		
		if( $name_used == true ) {
			$output_str .= '<select name="' . $name . '" id="' . $id . '" onChange="' . $action . '">';
		} else {
			$output_str .= '<select id="' . $id . '" onChange="' . $action . '">';
		}
		$output_str .= '<option value="' . $cid . '">&lt;&lt;==Left Category</option>';
		$output_str .= '<optgroup label="-------Select Subs-----"></optgroup>';
		for($i=0, $n=sizeof($categories); $i<$n; $i++) {
			$output_str .= '<option value="' . $categories[$i]['categories_id'] . '">' . $categories[$i]['categories_name'] . '</option>';
		}
		$output_str .= '</select>';
	}
	
	return $output_str;
}

function func_group_output_groups() {

}

function func_group_xxx() {

}

//content comments
function func_group_topic_load_comments($topics_id, $page) {
	global $groupObj;
	//
	$limit_length = 10;
	$limit_start = ($page - 1 ) * $limit_length;
	if( $limit_start < 0 ) {
		$limit_start = 0;
	}
	//
	$topic_comments = array();
	$limit_total = $groupObj->getTopicCommentsTotal($topics_id);
	//
	$groupObj->setQueryLimitStart($limit_start);
	$groupObj->setQueryLimitLength($limit_length);
	$comments = $groupObj->getTopicComments($topics_id, $limit_start, $limit_length);
	//
	$parameters = util_get_all_get_params(array('page'));
	$link_array = array(
				'page' => '',
				'parameters' => $parameters,
					);
	$navigation = util_common_navigation($link_array, $limit_total, $limit_start, $limit_length);
	
	//content
	global $tpl;
	
	$content_wrap = array(
			'comments' => $comments,
			'navigation' => $navigation,
					);
	$context_wrap = array(
			'URL' => CONFIG_URL,
			'URL_PREFIX' => CONFIG_URL_PREFIX,
				);
	$language_wrap = array();
	
	$content = func_get_tpl_content('group/blocks/group_block_topic_comments_listcomments.tpl', $content_wrap, $context_wrap, $language_wrap);
	
	return $content;
}
//
?>